﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:prim="clr-namespace:System.Windows.Markup.Primitives;assembly=WindowsBase"    xmlns:lineChart="clr-namespace:WpfChartingControlLibrary.PieChart" xmlns:Converters="clr-namespace:WpfChartingControlLibrary.Converters">

    <Converters:MyCloneConverter x:Key="MyCloneConverter"/>

    <ItemsPanelTemplate x:Key="CanvasPanel">
        <Canvas IsItemsHost="True">
            
            <!--
            <Canvas.Style>
                <Style>
                    <Style.Triggers>

                        <EventTrigger RoutedEvent="Control.Loaded">
                            <BeginStoryboard>
                                <Storyboard >
                                    <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Control.Opacity).(SolidColorBrush.Opacity)">
                                        <LinearColorKeyFrame KeyTime="0:0:1.3"
																Value="0.5"/>
                                    </ColorAnimationUsingKeyFrames>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                        
                        <DataTrigger Binding="{Binding Loaded}" Value="True">
                            
                            
                            
                            <DataTrigger.EnterActions>
                                <BeginStoryboard HandoffBehavior="Compose">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                                            <LinearColorKeyFrame KeyTime="0:0:0.3"
																Value="AliceBlue"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)">
                                            <LinearColorKeyFrame KeyTime="0:0:0.10"
                                                                                 Value="Black"/>

                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </DataTrigger.EnterActions>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Canvas.Style>
            -->
        </Canvas>
        
    </ItemsPanelTemplate>

    <Style x:Key="objectList" TargetType="{x:Type ListBox}">
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Canvas>
<!--
                        <Grid Panel.ZIndex="999" Canvas.Left="{Binding MyPath.Bounds.X}"
							Canvas.Top="{Binding MyPath.Bounds.Y}" >
                            <TextBlock Text="fdf"/>
                        </Grid>
-->

                    </Canvas>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>



    <!-- ItemContainerStyle with the Trigger for Selected -->
    <Style x:Key="RedGlowItemContainer" TargetType="{x:Type ListBoxItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Border Background="LightGray"
                    x:Name="IconBorder">
                        <Canvas>
                            <lineChart:PieSlice x:Name="fdf" Geometry="{Binding MyPath, NotifyOnTargetUpdated=True}"
                                            Fill="{Binding Path=BrushColor, Converter={StaticResource MyCloneConverter}}"
                                            PieSliceEffect="{Binding MyEffect, NotifyOnTargetUpdated=True}" ToolTip="{Binding ToolTipInfo}"/>

                        </Canvas>
                    </Border>
         <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter TargetName="IconBorder" Property="BitmapEffect">
                                <Setter.Value>
                                    <DropShadowBitmapEffect Color="Green"></DropShadowBitmapEffect>
                                                                    </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="fdf" Property="Fill">
                                <Setter.Value>
                                    <SolidColorBrush Color="Green"></SolidColorBrush>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
            
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <Style TargetType="{x:Type lineChart:PieChartControl}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type lineChart:PieChartControl}">
                    <Border Background="{TemplateBinding Background}"
						BorderBrush="{TemplateBinding BorderBrush}"
						BorderThickness="{TemplateBinding BorderThickness}">
                        
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="1*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="1*"/>
                            </Grid.RowDefinitions>

                            <Grid x:Name="PART_ChartGrid" Grid.Column="0" Background="{x:Null}"/>

                            <ListBox BorderThickness="0" VirtualizingStackPanel.IsVirtualizing="False" Grid.Column="0" HorizontalAlignment="Center" Background="Transparent" x:Name="PART_ChartItemsControl" 
								ItemsSource="{Binding DataList, RelativeSource={RelativeSource TemplatedParent}}" ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Disabled"                                     
							    Style="{StaticResource objectList}"
                                ItemContainerStyle="{StaticResource RedGlowItemContainer}"
                                SelectedValue="{Binding Path=SelectedValue, RelativeSource={RelativeSource TemplatedParent}}"
                                SelectedItem="{Binding Path=SelectedItem, RelativeSource={RelativeSource TemplatedParent}}" 
                                SelectionMode="{Binding Path=SelectionMode, RelativeSource={RelativeSource TemplatedParent}}"
                                SelectedValuePath="{Binding Path=SelectedValuePath, RelativeSource={RelativeSource TemplatedParent}}"
                                SelectedIndex="{Binding Path=SelectedIndex, RelativeSource={RelativeSource TemplatedParent}}">
                            </ListBox>

                            <ListBox VirtualizingStackPanel.IsVirtualizing="True" Grid.Column="1" BorderThickness="0" VerticalAlignment="Center"
								ItemsSource="{Binding DataList, RelativeSource={RelativeSource TemplatedParent}}">
                                <ListBox.Resources>
                                    <Style TargetType="{x:Type ListBoxItem}">
                                        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                                        <Setter Property="VerticalContentAlignment" Value="Top"/>



                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding LegendSelectable}" Value="false">
                                                <Setter Property="Template">
                                                    <Setter.Value>
                                                        <ControlTemplate>
                                                            <Grid  Margin="3" IsHitTestVisible="False" Background="#EBEBEB">
                                                                <Grid.ColumnDefinitions>
                                                                    <ColumnDefinition Width="20"/>
                                                                    <ColumnDefinition Width="Auto"/>
                                                                    <ColumnDefinition/>
                                                                </Grid.ColumnDefinitions>
                                                                <Grid.RowDefinitions>
                                                                    <RowDefinition/>
                                                                </Grid.RowDefinitions>
                                                                <Button Command="{Binding SelectFileCommand}"  Height="15" Width="15" Background="{Binding BrushColor}" Margin="0,0,5,0"/>
                                                                <TextBlock Grid.Column="1" Margin="3" Text="{Binding Label}"/>
                                                                <TextBlock Grid.Column="2" Margin="3" Text="{Binding Item}"/>
                                                            </Grid>
                                                        </ControlTemplate>
                                                    </Setter.Value>
                                                </Setter>
                                            </DataTrigger>
                                        </Style.Triggers>


                                    </Style>

                                </ListBox.Resources>
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <Grid  Margin="3" IsHitTestVisible="False" x:Name="grid" Background="#EBEBEB">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="20"/>
                                                <ColumnDefinition Width="Auto"/>
                                                <ColumnDefinition/>
                                            </Grid.ColumnDefinitions>
                                            <Grid.RowDefinitions>
                                                <RowDefinition/>
                                            </Grid.RowDefinitions>
                                            <Button IsHitTestVisible="True" Command="{Binding SelectFileCommand}"  Height="15" Width="15" Background="{Binding BrushColor}" Margin="0,0,5,0"/>
                                            <TextBlock Grid.Column="1" Margin="3" Text="{Binding Label}"/>
                                            <TextBlock Grid.Column="2" Margin="3" Text="{Binding Item}"/>
                                        </Grid>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>

                            </ListBox>
                        </Grid>
                    </Border>
                    
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>